package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 回/付款单alone字段枚举
 *
 * @author zcp
 * @version v1.0
 * @date 19/11/18 018 11:07
 * @update 19/11/18 018 11:07
 * @since v1.0
 */
@Getter
public enum SheetAloneEnum {
    //只有父，无子回款单（无明细）
    NORMAL(1, "enum.paymentSheetAlone.name.normal"),
    //父回款单
    PARENT(2, "enum.paymentSheetAlone.name.parent"),
    //子回款单（明细）
    CHILD(3, "enum.paymentSheetAlone.name.child"),
    ;
    /**
     * 类型code值
     */
    private Integer code;

    /**
     * 类型名称
     */
    private String name;

    SheetAloneEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 只有父无子和父
     *
     * @return java.util.List<java.lang.Integer>
     * @author 徐俊杰
     * @date 2019/12/12 9:26
     * @since v1.0
     */
    public static List<Integer> getNotChildCodeList() {
        List<Integer> notChildCodeList = new ArrayList<>();
        for (SheetAloneEnum cache : values()) {
            if (Objects.equals(SheetAloneEnum.CHILD, cache)) {
                continue;
            }
            notChildCodeList.add(cache.code);
        }
        return notChildCodeList;
    }

    /**
     * 只有父无子和子
     *
     * @return java.util.List<java.lang.Integer>
     * @author 徐俊杰
     * @date 2019/12/12 9:27
     * @since v1.0
     */
    public static List<Integer> getNotParentCodeList() {
        List<Integer> notParentCodeList = new ArrayList<>();
        for (SheetAloneEnum cache : values()) {
            if (Objects.equals(SheetAloneEnum.PARENT, cache)) {
                continue;
            }
            notParentCodeList.add(cache.code);
        }
        return notParentCodeList;
    }

    /**
     * 所有的code
     *
     * @return java.util.List<java.lang.Integer>
     * @author 徐俊杰
     * @date 2019/12/12 10:16
     * @since v1.0
     */
    public static List<Integer> getAllCodeList() {
        List<Integer> codeList = new ArrayList<>();
        for (SheetAloneEnum cache : values()) {
            codeList.add(cache.code);
        }
        return codeList;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
